﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NewRen.Models.ViewModel
{
    public class vTopic
    {
        public int ID { get; set; }


        public string Title { get; set; }


        public string Content { get; set; }


        public bool Top { get; set; }

        /// <summary>
        /// 发表时间
        /// </summary>
        public DateTime Time { set; get; }

        /// <summary>
        /// 上次回复时间
        /// </summary>
        public DateTime? LastReply { get; set; }
        
        public int PlateID { get; set; }

        public virtual Plate Plate { get; set; }
        
        public int UserID { get; set; }

        public virtual User User { get; set; }

        public int Reward { get; set; }

        public virtual ICollection<Reply> Replies { get; set; }

        /// <summary>
        /// 浏览
        /// </summary>
        public int Browses { get; set; }

        /// <summary>
        /// 举报
        /// </summary>
        public int Report { get; set; }

        /// <summary>
        /// 是否显示
        /// </summary>
        public bool IsColse { set; get; }

        /// <summary>
        /// 是否官方认证
        /// </summary>
        public bool IsOfficeIdentified { set; get; }

        public vTopic() { }

        public vTopic(Topic model)
        {
            DB db = new DB();
            this.ID = model.ID;
            this.Browses = model.Browses;
            this.Content = model.Content;
            this.IsOfficeIdentified = model.IsOfficeIdentified;
            this.IsColse = db.Plates.Find(model.PlateID).IsColse;
            this.LastReply = model.LastReply;
            this.Plate = db.Plates.Find(model.PlateID);
            this.PlateID = model.PlateID;
            this.Replies = model.Replies;
            this.Report = model.Report;
            this.Reward = model.Reward;
            this.Time = model.Time;
            this.Title = model.Title;
            this.Top = model.Top;
            this.User = db.Users.Find(model.UserID);
            this.UserID = model.UserID;
        }
    }
}